
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>new一个对象一定放在新生代吗？为什么？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>new一个对象一定放在新生代吗？为什么？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Java虚拟机（JVM）中的年轻代（Young Generation）通常由哪几个区域组成？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">年轻代由一个Eden区和两个Survivor区（S0和S1）组成。新创建的对象通常首先被分配在Eden区。</div>
          </div>
          <div class="card-source">来源: 1. 年轻代和老年代的划分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">为什么JVM默认将新对象分配到年轻代，而不是直接放入老年代？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">主要有三个原因：1. 为了优化短期对象，因为大多数对象生命周期很短；2. 年轻代采用的垃圾回收算法（如复制算法）可以实现快速回收；3. 可以有效减少老年代的负担，避免老年代频繁发生垃圾回收和内存碎片化。</div>
          </div>
          <div class="card-source">来源: 2. 对象分配到年轻代的原因</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">请解释Minor GC和Major GC（或Full GC）之间的核心区别。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Minor GC是针对年轻代的垃圾回收，通常速度较快。Major GC或Full GC是针对老年代的垃圾回收，过程更为复杂且耗时更长。对象只有在经过多次Minor GC后仍然存活，才会被晋升到老年代。</div>
          </div>
          <div class="card-source">来源: 3. 垃圾回收策略</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">一个对象是如何从年轻代“晋升”到老年代的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当一个年轻代的对象经过多次Minor GC（年轻代的垃圾回收）后仍然存活时，它就会被晋升到老年代。老年代专门用于存储生命周期较长的对象。</div>
          </div>
          <div class="card-source">来源: 3. 垃圾回收策略</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">文档中提到了哪些用于调整JVM堆内存及各代比例的参数？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档提到了三个JVM参数：-Xms（用于设置堆内存的初始大小）、-Xmx（用于设置堆内存的最大大小）和-XX:NewRatio（用于调整年轻代和老年代的比例）。</div>
          </div>
          <div class="card-source">来源: 4. JVM 配置和调优</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">老年代（Old Generation）在JVM内存管理中的主要作用是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">老年代主要用于存储生命周期较长的对象，即那些在年轻代经过多次垃圾回收后仍然存活的对象。</div>
          </div>
          <div class="card-source">来源: 1. 年轻代和老年代的划分</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
